﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DnDCharacterBuilder.Windows
{

    

    /// <summary>
    /// Interaction logic for ReferenceWindow.xaml
    /// </summary>
    public partial class ReferenceWindow : Window
    {
        PDFViewer PDView; 

        public ReferenceWindow()
        {
            InitializeComponent();

            if (DnDCharacterBuilder.Properties.Settings.Default.PHB1Path == "")
            {
                MessageBox.Show("Please select the proper reference file in Options/Settings.", "Invalid reference", MessageBoxButton.OK, MessageBoxImage.Error);
                //this.Close();
            }
            else
            {
                try
                {

                    PDView = new PDFViewer(DnDCharacterBuilder.Properties.Settings.Default.PHB1Path);
                    PDFHost.Child = PDView;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error loading reference file. Check Options/Settings.\n\n" + ex.Message, "Invalid reference", MessageBoxButton.OK, MessageBoxImage.Error);
                    //this.Close();
                }
            }
        }

        public void Nav(int page)
        {
            PDView.Nav(page);
        }

        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            if (this.Owner != null)
                this.Owner.Focus();
            base.OnClosing(e);
        }
    }
}
